function initFlow() {
    $('select[name=flowSort]').on('change', function () {
        var url = $('#url').val();
        var id = $(this).val();
        var index = layer.load(2, {shade: false});
        $.get(url + '?id=' + id, function (res) {
            console.log(res)
            var html = '';
            for (var i = 0; i < res.length; i++) {
                html += '<tr class="text-c">';
//                html += '<td><input class="more" name="id[]" type="checkbox" value="'+res[i].flow_id+'"></td>';
                html += '<td>' + res[i].flow_id + '</td>';
                html += '<td>' + res[i].flow_name + '</td>';
                html += '<td>' + res[i].flow_no + '</td>';
                html += '<td>' + res[i].is_show + '</td>';
                html += '<td><i class="iconfont icon1">&#x' + res[i].icon + ';</i></td>';
                html += '<td>' + res[i].color + '</td>';
                html += '<td><a style="text-decoration:none" href="/index.php/Home/index/save/id/' + res[i].flow_id + '" title="编辑"><i class="iconfont icon-xiugai" style="font-size:16px;"> </i></a></td>';
                html += '</tr>';
            }
            $('.ftable .tbody').html(html);
            layer.close(index);
        })
    })
    
}

function initUser() {
    $('.clearPwd').on('click', function () {
        var url = $(this).attr('data-url');
        layer.confirm('确定要清空密码吗?', {
            closeBtn: 0,
            btn: ['确定', '取消'] //按钮
        }, function () {
            var index = layer.load(1, {shade: false});
            $.get(url, function (res) {
                console.log(res)
                layer.msg(res.info);
                location.reload();
            })
        }, function (index) {
            layer.close(index);
        })
    })

    //按部门查询用户
    $('.searchUser').on('click', function () {
        $('form').submit();
    })

    //展开用户基本信息
    $('.open').on('click', function () {
        if ($('.childCate').css('display') == 'none') {
            $('.childCate').show();
            $(this).children('label').text('收起用户基本信息');
            $(this).children('img').attr('src', '/Public/Admin/images/arrow-up.png')
        } else {
            $('.childCate').hide();
            $(this).children('label').text('展开用户基本信息');
            $(this).children('img').attr('src', '/Public/Admin/images/arrow-down.png')
        }
    })

    //选择角色
    $('.addPriv').on('click', function () {
        var document_w = $(window).width();
        var document_h = $(window).height();
        var layer_w = '300';
        var layer_h = '500';
        var w = (document_w - layer_w) / 2;
        var h = (document_h - layer_h) / 2;
        
        var key_id = $(this).attr('data-key');
        var className = '.addPriv_' + key_id;
        var field = $(className).attr('data-key');
        layer.open({
            type: 2,
            title: [
                "选择角色",
                'background-color: #437dba;color:#fff;text-align:center;font-size:1.4em',
            ],
            area: [layer_w + 'px', layer_h + 'px'], //宽高
            offset: [h + 'px', w + 'px'], //弹出位置 [top,left]
            content: "/index.php/Home/Index/layer/type/7/key/" + key_id + "/field/" + field
        })
    })

    //清空
    $('.delData').on('click', function () {
        $(this).parent('.value').find('.textarea span:not(:first)').remove();
    })

    //删除单个用户
    $('body').on('click', '.delOperator', function () {
        $(this).parent('span').remove();
    })

    //更新用户企业邮箱
    $('.updateEmail').on('click', function () {
        var url = $(this).attr('data-url');
        var index = layer.load(2, {shade: false});
        $.get(url, function (res) {
            console.log(res);
            if (res) {
                layer.msg('更新成功', {'icon': 6});
                setTimeout(function () {
                    location.reload();
                }, 1000);
            }
        })
    })

    //同步通讯录
    $('.updateAddress').on('click', function () {
        var url = $(this).attr('data-url');
        $.get(url, function (res) {
            console.log(res);
            if (res.status == 1) {
                layer.msg('同步成功', {'icon': 6});
                setTimeout(function () {
                    location.reload();
                }, 1000);
            }else{
                layer.msg('同步失败', {'icon': 5});
            }
        })
    })
}